package banque;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.OneToMany;
import javax.persistence.InheritanceType;

@Entity 
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorValue("Ct")
public class Compte implements Serializable{
	
	final static int STDACCOUNT = 0;
	final static int SPRACCOUNT = 2;
	final static int PTACCOUNT = 1;
	
	@Id
	@GeneratedValue
	int id;
	double solde;
	
	@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.REMOVE})
	private Set<Operation> listeoperations = new HashSet<Operation>();
	
	public Compte(){
		super();
		
	}
	
	public void nouvelleOperation(double montant, int type){
		getListeoperations().add(new Operation(montant,type));
	}
	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public double getSolde() {
		return solde;
	}

	public void setSolde(double solde) {
		this.solde = solde;
	}

	public Set<Operation> getListeoperations() {
		return listeoperations;
	}

	public void setListeoperations(Set<Operation> listeoperations) {
		this.listeoperations = listeoperations;
	}


	
	

}
